Skip to content

feat(dflash): expose effective runtime state - #3003

Closed
joshuaswarren wants to merge 4 commits into
jundot:mainfrom
joshuaswarren:feat/dflash-effective-state
Closed

joshuaswarren wants to merge 4 commits into
jundot:mainfrom
joshuaswarren:feat/dflash-effective-state

Conversation

@joshuaswarren

Copy link
Copy Markdown
Contributor

Summary

Expose requested versus effective DFlash state through the existing authenticated GET /v1/models/status response.

DFlash intentionally fails soft: when startup fails, oMLX serves the model through its natural batched/VLM engine and still returns 200. It can also switch permanently to that inner fallback after a successful load for long-context or multimodal requests. Until now an API client could not distinguish either fallback from an active DFlash engine.

Each model status row now adds:

  • effective_engine: the backend serving the model now
  • dflash_requested: whether DFlash was requested for this load
  • dflash_active: whether DFlash is currently serving
  • dflash_fallback_reason: a bounded, path-redacted reason when requested DFlash is not active

No endpoint, dependency, or fallback policy changes. Existing clients receive an additive payload, and normal fallback continues serving successfully.

Runtime state

The status follows both load-time and post-load behavior:

  • DFlash starts successfully -> effective_engine=dflash, dflash_active=true
  • missing draft/dependency, unsupported deployment, init/start failure -> natural engine, dflash_active=false, reason populated
  • long-context or multimodal runtime fallback -> live natural engine, dflash_active=false, trigger populated
  • DFlash not requested -> requested/active false, no reason
  • unload -> effective state cleared

DFlashEngine exposes read-only fallback state; the pool does not inspect private engine fields. Runtime fallback triggers must supply a reason, so a new trigger cannot silently omit observability.

Privacy and bounds

Fallback text crosses an API boundary. It is therefore whitespace-collapsed, filesystem paths are replaced with <path>, and output is limited to 200 characters. Static reasons are used where possible; stack traces are not exposed.

Example fallback:

{
  "id": "Qwen3.8-27B",
  "loaded": true,
  "engine_type": "batched",
  "effective_engine": "batched",
  "dflash_requested": true,
  "dflash_active": false,
  "dflash_fallback_reason": "DFlash runtime fallback: prompt of 14000 tokens reached the DFlash context limit of 8192"
}

Client assertion:

curl -s localhost:10240/v1/models/status |
  jq -e '.models[] | select(.id=="Qwen3.8-27B") | .dflash_active'

Verification

On macOS / Python 3.13:

  • 324 focused engine-pool, DFlash lifecycle, multimodal, memory-guard, and status-endpoint tests passed
  • final changed-surface rerun: 40 passed
  • ruff clean on dflash.py and the changed DFlash tests
  • independent spec-compliance review passed
  • independent code-quality review found a post-load fallback gap; fixed and re-reviewed with no remaining P0-P2 findings

The remaining whole-file ruff findings in engine_pool.py reproduce on upstream code and were deliberately not expanded into this PR.

Closes #2896.

@joshuaswarren
joshuaswarren force-pushed the feat/dflash-effective-state branch from 4323d58 to bf83461 Compare August 22, 2026 14:52
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

Rebased onto main @ 2df39bfc and fixed the one real issue I found in self-review.

Change: the fallback-reason path regex excluded whitespace, so a home path with a space (/Users/Joshua Warren/...) leaked unredacted into /v1/models/status. Replaced it with a delimiter-bounded matcher that redacts spaced and quoted paths while leaving non-paths like a/b alone.

Tests: added three regression cases (spaced path, quoted path, ratio non-path). tests/test_dflash_effective_state.py (21) and tests/test_dflash_multimodal_fallback.py (22) both pass on macOS 15 / Python 3.13.

No other changes. Ready for review.

@joshuaswarren
joshuaswarren force-pushed the feat/dflash-effective-state branch 2 times, most recently from 50c6b05 to a229fe5 Compare August 24, 2026 22:17
@joshuaswarren
joshuaswarren force-pushed the feat/dflash-effective-state branch from a229fe5 to a6cd815 Compare September 20, 2026 16:58
@joshuaswarren
joshuaswarren force-pushed the feat/dflash-effective-state branch 2 times, most recently from 1e1f6cc to 633ff52 Compare October 9, 2026 11:46
@joshuaswarren

joshuaswarren commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

After rebasing onto current main, this PR keeps upstream's current behaviour in batched-drafter mode and for decision models: it only reports the effective engine state and does not change which engine runs or when a DFlash load declines. Extending the reported status to those two cases can be a follow-up if you want it.

@joshuaswarren
joshuaswarren force-pushed the feat/dflash-effective-state branch from 633ff52 to 4756895 Compare October 10, 2026 00:32
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (c0b1056), two commits, no behavior change. One conflict, in omlx/engine_pool.py: the import block, where #4396 had dropped import os; the rebased file keeps import re (used by the path redaction) and no os. The previous CI failure was not from this PR: tests/test_heterogeneous_pool_probe.py imports a benchmarks module that is not on the runner (16697 passed, 1 error), and #4393 removes that test. Local check: the changed files parse; I could not run the suite on this Linux machine (no Metal mlx wheel), so the macOS CI run on this head is the test.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

CI on the last rebase (4756895b5): 16643 passed, 1405 skipped, 1 failed. The failure is tests/test_cluster_rdma_stage_transport.py::test_rank_zero_routes_its_incoming_edge_over_rdma_when_both_ends_agree: a two-process test where the receiver waited 60 s and the sender 20 s for each other (TimeoutError: rank 1 sent nothing over td96c3c9c for 60 s). This PR does not touch omlx/cluster/ or that test (changed files: omlx/engine/dflash.py, omlx/engine_pool.py, three dflash tests, one doc). The previous failure on 633ff5265 was an ImportError in tests/test_heterogeneous_pool_probe.py, which the rebase fixed.

I cannot re-run the job (it needs admin rights on the repo). A maintainer re-run of the failed job should pass if the timeout is a runner-load flake.

…sons

The path regex excluded whitespace, so /Users/Joshua Warren/... leaked
unredacted into the API status response. Match path segments up to
delimiters instead of whitespace, and add regression tests for spaced
paths, quoted paths, and the a/b ratio non-path.
Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
@joshuaswarren
joshuaswarren force-pushed the feat/dflash-effective-state branch from 4756895 to 392d6b7 Compare October 25, 2026 04:43
Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

Hi @jundot — friendly ping on this PR. It is rebased onto current main; the last CI run was 16643 passed / 1405 skipped / 1 failed, and that failure is a two-process cluster transport timeout in a file this PR does not touch (details in the thread). Happy to rebase again or reshape anything if that helps get it reviewed.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

closing for inactivity, no maintainer review after 78 days and one ping, rebased and green at close, will reopen on request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DFlash 2: fallback is silent when dflash_enabled is set (v0.6.3rc1 fixed the packaging half)

1 participant